/////////////////////////////////////////////////////////////////////
//
//  MOE Framework (Meta Object Encapsulation Framework)
//
//  Original Author: Wiksy Wang, 2011
//
/////////////////////////////////////////////////////////////////////

#ifndef MOE_NAME_NAME_PATH_REF_H
#define MOE_NAME_NAME_PATH_REF_H

#include "NamePath.h"

namespace MOE
{

namespace Name
{

class NamePathRef
{
public:
	NamePathRef(const NamePath& obj, size_t startIndex = 0, size_t endIndex = (size_t)-1);
	NamePathRef(const NamePathRef& other, size_t startIndex = 0, size_t endIndex = (size_t)-1);

	RawByteVectorRef GetPath() const { return _obj.GetSegment(_startIndex, _endIndex); }
	size_t GetSplitCount() const { return _endIndex - _startIndex; }

	unsigned int GetDelimiter() const { return _obj.GetDelimiter(); }
	size_t GetCharSize() const { return _obj.GetCharSize(); }

	// Gets the sub path starting from the index-th split. This version creates a reference object to RawByteVector.
	RawByteVectorRef GetSubPath(size_t index) const;

	// Gets the path segment from startIndex to endIndex (inclusive). This version creates a reference object to RawByteVector.
	RawByteVectorRef GetSegment(size_t startIndex, size_t endIndex) const;

	RawByteVectorRef GetFirstSegment() const { return GetSegment(0, 0); }
	RawByteVectorRef GetLastSegment() const { return GetSubPath(GetSplitCount()); }

private:
	const NamePath& _obj;
	size_t _startIndex;
	size_t _endIndex;

};

}

}

#endif
